<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组案例</title>
    <script>
        //数组去重,数组长度n，重复元素计数器cnt=0。顺序便历数组，如果a[i]已经出现过，则交换a[i]和a[n-cnt-1]，cnt自增1,最后数组长度为n-cnt;
        var arr = [0, 0, 2, 2, 3, 4, 3, 6, 7, 8, 4, 6, 7, 10, 23];
        var newArr = [];
        var j;
        for (var i = 0; i < arr.length; i++) {
            newArr[newArr.length] = arr[i];
            for (j = i + 1; j < arr.length; j++) {
                if (arr[i] === arr[j]) {
                    newArr.length--;
                    break;
                }
            }
        }
        console.log(newArr);

        //
    </script>
</head>

<body>

</body>

</html>